package com.fs.uc.base.repo;

import com.fs.uc.base.domain.Org;
import com.fs.uc.base.domain.Role;
import com.fs.uc.base.domain.RoleType;
import io.quarkus.hibernate.orm.panache.PanacheRepository;

import javax.enterprise.context.ApplicationScoped;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @author 崔超
 * 2021/12/6
 */
@ApplicationScoped
public class RoleRepository implements PanacheRepository<Role> {

    public List<Role> findByNames(List<String> names) {
        Map<String, Object> params = new HashMap<>();
        params.put("list", names);
        return list("select r from Role r where name in (:list)", params);
    }

    public List<Role> findByIds(List<Long> roleIds) {
        Map<String, Object> params = new HashMap<>();
        params.put("roleIds", roleIds);
        return list("select r from Role r where id in (:roleIds)", params);
    }

    public List<Role> findByType(RoleType roleType) {
        return list("type",roleType);
    }
}
